import requests

from urllib.parse import quote
from somecookie import readCookie,writeCookies

def main(content):
    headers = {
        'Host': 'weibo.com',
        'pragma': 'no-cache',
        'cache-control': 'no-cache',
        'x-xsrf-token': 'g8pC6Rv-ryKwSejPw1T8BCim',
        'traceparent': '00-122638d2c50941abd1f56aa963690c3b-716d2dfd58653f60-00',
        'sec-ch-ua-mobile': '?0',
        'client-version': 'v2.34.88',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36',
        'content-type': 'application/x-www-form-urlencoded',
        'accept': 'application/json, text/plain, */*',
        'x-requested-with': 'XMLHttpRequest',
        'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="102", "Google Chrome";v="102"',
        'sec-ch-ua-platform': '"Windows"',
        'origin': 'https://weibo.com',
        'sec-fetch-site': 'same-origin',
        'sec-fetch-mode': 'cors',
        'sec-fetch-dest': 'empty',
        'referer': 'https://weibo.com/',
        'accept-language': 'zh-CN,zh;q=0.9',
        'cookie':'SUB='+readCookie('SUB')+'; XSRF-TOKEN=g8pC6Rv-ryKwSejPw1T8BCim;'
    }
    data = 'content=' + quote(content) + '&pic_id=&visible=0&share_id=&media=%7B%7D&vote=%7B%7D&approval_state=0'
    response = requests.post('https://weibo.com/ajax/statuses/update', headers=headers, data=data)
    print(response.text)
    return  response



main('微博需要发送的内容rree')





